package com.lzy.product.service.impl;

import com.lzy.framework.core.utils.DozerUtils;
import com.lzy.product.dao.AgentPromoteMapperExt;
import com.lzy.product.dtos.agent.AgentPromoteDto;
import com.lzy.product.entity.AgentPromote;
import com.lzy.product.service.AgentPromoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class AgentPromoteServiceImpl implements AgentPromoteService {

    @Autowired
    private AgentPromoteMapperExt agentPromoteMapperExt;


    @Override
    public Long insert(AgentPromoteDto dto) {
        AgentPromote agentPromote = DozerUtils.map(dto, AgentPromote.class);
        return agentPromoteMapperExt.insertSelective(agentPromote) > 0 ? agentPromote.getId() : 0;
    }

    @Override
    public Boolean update(AgentPromoteDto dto) {
        return agentPromoteMapperExt.updateByPrimaryKeySelective(DozerUtils.map(dto, AgentPromote.class)) > 0;
    }

    @Override
    public Boolean delete(Long id) {
        return null;
    }

    @Override
    public Boolean remove(Long id) {
        return null;
    }

    @Override
    public AgentPromoteDto findById(Long id) {
        return DozerUtils.map(agentPromoteMapperExt.selectByPrimaryKey(id), AgentPromoteDto.class);
    }

    @Override
    public List<AgentPromoteDto> query(AgentPromoteDto dto) {
        return null;
    }

    @Override
    public Boolean deleteByProtocolId(Long protocolId) {
        return agentPromoteMapperExt.deleteByProtocolId(protocolId);
    }

    @Override
    public AgentPromoteDto queryByProtocolIdAndCriticalValue(Long protocolId, BigDecimal criticalValue) {
        return agentPromoteMapperExt.queryByProtocolIdAndCriticalValue(protocolId, criticalValue);
    }
}
